<template>
  <div class="login">
    <h1>登录页面</h1>
    <input type="text" v-model="uname" placeholder="请输入用户名"></input>
    <input type="password" v-model="password" placeholder="请输入密码"></input>
    <button @click="login">登录</button>
  </div>
</template>

<script>
export default {
  name: 'login',
  components: {},
  props: {},
  data() {
    return {
      uname:'',
      password:''
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    login() {
      //登录成功
      //将用户信息保存到sessionStorage中
      sessionStorage.setItem('user',JSON.stringify({
        username:this.uname,
        password:this.password
      }))
      // 跳转到首页 编程式路由
      this.$router.replace({
        name:'main'
      })
    }
  }
}
</script>

<style scoped>

</style>